package com.example.bidc_work_state;

import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class SingleItemActivity extends Activity {
	
    //JSON Node Names 
    private static final String TAG_TITLE = "Title";
    private static final String TAG_STATUS = "status";
    private static final String TAG_DUE_DATE = "DueDate";
    private static final String TAG_ID = "ID";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_single_item);
        
       TextView txtTitle = (TextView) findViewById(R.id.text_view_title_item);
       TextView txtDueDate = (TextView) findViewById(R.id.text_view_duedate_item);
       TextView txtStatus = (TextView) findViewById(R.id.text_view_status_item);
       final Button button_back = (Button) findViewById(R.id.button_back);
       
       Intent i = getIntent();
       // getting attached intent data
       String v_title = i.getStringExtra(TAG_TITLE);
       String v_duedate = i.getStringExtra(TAG_DUE_DATE);
       String v_status = i.getStringExtra(TAG_STATUS);
       // displaying selected product name
       txtTitle.setText(v_title);
       txtDueDate.setText(v_duedate);
       txtStatus.setText(v_status);
       
       
       
       //Press button back event
       OnClickListener back_listenner = new OnClickListener() {			
			@Override
			public void onClick(View v) {				
				Intent mainview_intent = new Intent(getApplicationContext(),MainViewActivity.class);
				startActivity(mainview_intent);				
			}
		};
		button_back.setOnClickListener(back_listenner);
		super.onPause();	
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.single_item, menu);
		return true;
	}
	
	 @Override  
	    public boolean onOptionsItemSelected(MenuItem item) {  
	        switch (item.getItemId()) {  
            case R.id.item1:  
                Toast.makeText(getApplicationContext(),"Item 1 Selected",Toast.LENGTH_LONG).show();  
              return true;     
    
              case R.id.item2:  
                  Toast.makeText(getApplicationContext(),"Item 2 Selected",Toast.LENGTH_LONG).show();  
                return true;     
                
              case R.id.item3:  
                  Toast.makeText(getApplicationContext(),"Item 3 Selected",Toast.LENGTH_LONG).show();  
                return true;     
    
                default:  
                  return super.onOptionsItemSelected(item);  
          }  
	    }  	
}
